﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.Foundation.Collections;
using Windows.ApplicationModel.Resources;

namespace CC98
{
    internal class ResourcesHelper : DependencyObject
    {
        public IObservableMap<string,object> Resources
        {
            get { return (IObservableMap<string,object>)GetValue(ResourcesProperty); }
            private set { SetValue(ResourcesProperty, value); }
        }

        public static readonly DependencyProperty ResourcesProperty =
            DependencyProperty.Register("Resources", typeof(IObservableMap<string,object>), typeof(ResourcesHelper), new PropertyMetadata(new ResourceResolver()));

        public static string GetString(string key)
        {
            return _loader.GetString(key);
        }

        private static readonly ResourceLoader _loader = new ResourceLoader();
    }

    internal class ResourceResolver : IObservableMap<string, object>
    {
        public ResourceResolver()
        {
            this._loader = new ResourceLoader();
        }

        public event MapChangedEventHandler<string, object> MapChanged;

        public void Add(string key, object value)
        {
            throw new NotImplementedException();
        }

        public bool ContainsKey(string key)
        {
            var value = this._loader.GetString(key);
            return value != null;
        }

        public ICollection<string> Keys
        {
            get { throw new NotImplementedException(); }
        }

        public bool Remove(string key)
        {
            throw new NotImplementedException();
        }

        public bool TryGetValue(string key, out object value)
        {
            value = this._loader.GetString(key);
            return value != null;
        }

        public ICollection<object> Values
        {
            get { throw new NotImplementedException(); }
        }

        public object this[string key]
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public void Add(KeyValuePair<string, object> item)
        {
            throw new NotImplementedException();
        }

        public void Clear()
        {
            throw new NotImplementedException();
        }

        public bool Contains(KeyValuePair<string, object> item)
        {
            throw new NotImplementedException();
        }

        public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
        {
            throw new NotImplementedException();
        }

        public int Count
        {
            get { throw new NotImplementedException(); }
        }

        public bool IsReadOnly
        {
            get { throw new NotImplementedException(); }
        }

        public bool Remove(KeyValuePair<string, object> item)
        {
            throw new NotImplementedException();
        }

        public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
        {
            throw new NotImplementedException();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            throw new NotImplementedException();
        }

        private ResourceLoader _loader;
    }
}
